﻿using System;
using System.IO;
using Golos.Helper;

namespace Golos.Users.Configuration
{
    public class Settings
    {
        public int ServerPort { get; private set; }
        public string DbConnectionString { get; private set; }

        public static Settings ReadFromFile()
        {
            SettingsManager settingsManager = SettingsManager.ReadFromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFileName));
            int serverPort = settingsManager.GetInt32Value("CachePort");
            string dbConnectionString = settingsManager.GetValue("DB.ConnectionString");
            return new Settings(serverPort, dbConnectionString);
        }

        private Settings(int serverPort, string dbConnectionString)
        {
            ServerPort = serverPort;
            DbConnectionString = dbConnectionString;
        }

        private const string configFileName = @"settings\config";
    }
}
